package cn.lj.user.controller;

import cn.lj.base.Exception.BusinessException;
import cn.lj.base.util.AjaxResult;
import cn.lj.user.dto.UserDto;
import cn.lj.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Api(tags = "用户接口",description = "用户接口详细描述")
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/register")/*用户注册*/
    @ApiOperation(value = "用户注册",notes = "用户根据手机或者用户名注册")
    public AjaxResult register(@RequestBody UserDto userDto){
        try {
            userService.reginster(userDto);
            return AjaxResult.me();
        }catch (BusinessException e){
            System.out.println("1111111");
            return AjaxResult.me().setAjaxResult(e.getMessage());
        }catch (Exception e){
            return AjaxResult.me().setAjaxResult(e.getMessage());
        }
    }

}
